package com.rulin.asp.business.log.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rulin.asp.business.log.entity.QuestionLog;
import com.rulin.asp.business.log.mapper.QuestionLogMapper;

@Service
public class QuestionLogService {

	@Autowired
	private QuestionLogMapper questionLogMapper;
	
	public void addQuestionLog(QuestionLog log){
		log.setOperateTime(new Date());
		String logMessage = null;
		//1,新增；2，修改；3，保存；4，拣取；5，认领；6，退回；7，回复；8，指派；9，删除；10，发布
		switch (Integer.valueOf(log.getOperateType())) {
		case 1:
			logMessage = log.getUserName()+"创建了题目信息";
			break;
		case 2:
			logMessage = log.getUserName()+"修改了题目信息";
			break;
		case 3:
			logMessage = log.getUserName()+"保存了题目信息";
			break;
		case 4:
			logMessage = log.getUserName()+"拣取了该题目";
			break;
		case 5:
			logMessage = log.getUserName()+"认领了该题目";
			break;
		case 6:
			logMessage = log.getUserName()+"退回了该题目";
			break;
		case 7:
			logMessage = log.getUserName()+"回复了该题目";
			break;
		case 8:
			logMessage = log.getUserName()+"指派了题目给"+log.getAcceptorName();
			break;
		case 9:
			logMessage = log.getUserName()+"删除了该题目";
			break;
		case 10:
			logMessage = log.getUserName()+"发布了该题目";
			break;
		default:
			break;
		}
		log.setLogMessage(logMessage);
		questionLogMapper.insert(log);
	}
	
	public List<QuestionLog> getQuestionLogsByQuesId(String quesId){
		return questionLogMapper.selectQuesLogsByQuesId(quesId);
	}
}
